package com.ruoyi.web.controller.system;

import com.ruoyi.web.service.C2PipeSucRateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/C2PipeSucRate")
public class C2PipeSucRateController {

    @Autowired
    private C2PipeSucRateService c2PipeSucRateService;

    /**
     * 获取每个 Node 在每个自然月的集成成功率
     * @return 包含每个 nodeName 和每个月份的成功率数据
     */
    @GetMapping("/byWeeks")
    public ResponseEntity<Map<String, Object>> getNodeSuccessRateByMonths() {
        // 获取每个 nodeName 每个月的成功率数据
        Map<String, Object> response = c2PipeSucRateService.getNodeSuccessRateByWeeks();

        return ResponseEntity.ok(response);
    }

    @GetMapping("/byMonth")
    public ResponseEntity<Map<String, Object>> getNodeSuccessRateByMonth() {
        // 获取每个 nodeName 每个月的成功率数据
        Map<String, Object> response = c2PipeSucRateService.getNodeSuccessRateByMonth();

        return ResponseEntity.ok(response);
    }

    /**
     * 获取每季度的节点成功率
     */
    @GetMapping("/byQuarters")
    public ResponseEntity<Map<String, Object>> getNodeSuccessRateByQuarters() {
        // 获取每个 nodeName 每季度的成功率数据
        Map<String, Object> response = c2PipeSucRateService.getNodeSuccessRateByQuarters();

        return ResponseEntity.ok(response);
    }


    @GetMapping("/byYears")
    public ResponseEntity<Map<String, Object>> getNodeSuccessRateByYears() {
        // 获取每个 nodeName 每个月的成功率数据
        Map<String, Object> response = c2PipeSucRateService.getNodeSuccessRateByYears();

        return ResponseEntity.ok(response);
    }
}
